# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
version: 6.4.0
var:
  container:
    use_container: 1
  deps:
    - build-essential
    - libmpc-dev
  setup: |
    [% c("var/setarch") -%]
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    export PATH="/var/tmp/dist/gcc/bin:$PATH"
    [% IF c("var/osname") == "linux-i686" -%]
    export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib
    [% ELSE -%]
    export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib64
    [% END -%]

    # Config options for hardening-wrapper
    export DEB_BUILD_HARDENING=1
    export DEB_BUILD_HARDENING_STACKPROTECTOR=1
    export DEB_BUILD_HARDENING_FORTIFY=1
    export DEB_BUILD_HARDENING_FORMAT=1
    export DEB_BUILD_HARDENING_PIE=1

    # Make sure we use the hardening wrapper
    pushd /var/tmp/dist/gcc/bin
    cp /usr/bin/hardened-cc ./
    mv gcc gcc.real
    mv c++ c++.real
    mv g++ g++.real
    ln -sf hardened-cc gcc
    ln -sf hardened-cc c++
    ln -sf hardened-cc g++
    popd

targets:
  windows:
    var:
      configure_opt: --disable-multilib --enable-languages=c,c++
      arch_deps:
        - libc6-dev
        - zlib1g-dev
  linux-i686:
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-system-zlib
      arch_deps:
        - hardening-wrapper
        - libc6-dev
        - zlib1g-dev
  linux-x86_64:
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-arch_32=i686
      arch_deps:
        - hardening-wrapper
        - libc6-dev-i386
  linux-arm:
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-arch_32=i686
      arch_deps:
        - hardening-wrapper
        - libc6-dev-i386
input_files:
  - project: container-image
  - URL: 'https://ftp.gnu.org/gnu/gcc/gcc-[% c("version") %]/gcc-[% c("version") %].tar.xz'
    sha256sum: 850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4
